/*
 * Person.java
 * Team qq 2011
 */
package com.google.code.timetrail.backend;

import java.io.Serializable;

/**
 * @author Jake Gibel
 * @version $Revision: 1.0 $
 */
public class Person implements Serializable {
	/**
	 * Person's SerialVersion ID, to be changed when the object is changed
	 **/
	private static final long serialVersionUID = 40L;

	/**
	 * health - the person's current health.
	 */
	protected int health;

	/**
	 * death - the person's probability of death.
	 */
	protected int death;
	
	/**
	 * illness - the person's probability of illness.
	 */
	protected int illness;

	/**
	 * name - the person's name.
	 */
	protected String name;

	/**
	 * the status of the Person, whether it be healthy, dead, sick, etc.
	 */
	private String status;

	/**
	 * the array of the skill levels of the person
	 */
	private int[] skills;

	/** Standard starting money except for Entrepreneurs and Nutritionists */
	private static final int START_MONEY = 800;

	/**
	 * Standard amount of starting fuel cells.
	 */
	private static final int START_FCELL = 0;

	/**
	 * standard amount of starting food.
	 */
	private static final int START_FOOD = 0;

	/**
	 * standard amount of starting hull parts.
	 */
	private static final int START_HULLP = 0;

	/**
	 * standard amount of starting fuel capacitors.
	 */
	private static final int START_FCAP = 0;

	/**
	 * standard amount of starting illness factors.
	 */
	private static final int START_ILL = 5;

	/**
	 * standard amount of starting death factor.
	 */
	private static final int START_DEATH = 5;

	/**
	 * standard amount of starting health.
	 */
	private static final int START_HEALTH = 95;

	/**
	 * Position two
	 */
	private static final int POSITION_TWO = 2;
	
	/**
	 * Position three
	 */
	private static final int POSITION_THREE = 3;
	
	/**
	 * instantiates the persons illness and death probability as well as their
	 * health.
	 */
	public Person() {
		illness = START_ILL;
		death = START_DEATH;
		health = START_HEALTH;
		status = "Healthy";
		final int[] skillSet = { 0, 0, 0, 0 };
		skills = skillSet;
	}

	/**
	 * sets the person's name then instantiates the persons illness and death
	 * probability as well as their health.
	 * 
	 * @param name
	 *            their name
	 */
	public Person(String name) {
		this();
		this.name = name;
	}

	/**
	 * Adds an initial bonus to the inventory typically depending on what
	 * subclass of person is recognized
	 * 
	 * @param inv
	 *            the inventory that will receive the bonus
	 */
	public void initialBonus(Inventory inv) {
		inv.addItem(START_MONEY, inv.getMoney());
		inv.addItem(START_FOOD, inv.getFood());
		inv.addItem(START_FCELL, inv.getFuelCells());
		inv.addItem(START_HULLP, inv.getHullParts());
		inv.addItem(START_FCAP, inv.getHullParts());
	}

	/**
	 * returns if the person is alive.
	 * 
	 * @return true if health is above zero
	 */
	public boolean isAlive() {
		return health > 0;
	}

	/**
	 * returns the illness factor.
	 * 
	 * @return illness factor
	 */
	public int getIllness() {
		return illness;
	}

	/**
	 * sets the player's illness factor.
	 * 
	 * @param illness
	 *            the illness factor that you want to set the players to.
	 */
	public void setIllness(int illness) {
		this.illness = illness;
	}

	/**
	 * returns the death factor.
	 * 
	 * @return the player's death factorr
	 */
	public int getDeath() {
		return death;
	}

	/**
	 * set the player's death factor.
	 * 
	 * @param death
	 *            the death factor that you want to change it to
	 */
	public void setDeath(int death) {
		this.death = death;
	}

	/**
	 * returns the player's health.
	 * 
	 * @return the player's health
	 */
	public int getHealth() {
		return health;
	}

	/**
	 * Method setHealth.
	 * 
	 * @param health
	 *            int
	 */
	public void setHealth(int health) {
		this.health = health;
	}

	/**
	 * returns the player's name.
	 * 
	 * @return the player's name
	 */
	public String getName() {
		return name;
	}

	/**
	 * set the player's name.
	 * 
	 * @param name
	 *            the player's name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param status
	 *            the new status of the Person
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * Sets the Person's status to Dead
	 */
	public void die() {
		this.status = "Dead";
	}

	/**
	 * Sets the Person's status to Sick
	 */
	public void sick() {
		this.status = "Sick";
	}

	/**
	 * @return true if the person's Status is Dead, false if it isn't
	 */
	public final boolean isDead() {
		return status.equals("Dead");
	}

	/**
	 * @return true if the person's status is Sick, false otherwise
	 */
	public final boolean isSick() {
		return status.equals("Sick");
	}

	/**
	 * Sets the Person's status to Healthy
	 */
	public void heal() {
		this.status = "Healthy";
	}

	/**
	 * @return The Person's status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * Sets the skill set to a particular set of values, instead of the default
	 * 
	 * @param skillSet
	 */
	public void setSkills(int[] skillSet) {
		skills[0] = skillSet[0];
		skills[1] = skillSet[1];
		skills[POSITION_TWO] = skillSet[POSITION_TWO];
		skills[POSITION_THREE] = skillSet[POSITION_THREE];
	}

	/**
	 * Sets the skill set to a default set of values which is zero, for every
	 * value
	 */
	public void intializeSkills() {
		skills[0] = 0;
		skills[1] = 0;
		skills[POSITION_TWO] = 0;
		skills[POSITION_THREE] = 0;
	}

	/**
	 * @return an array of the skill levels of the Person
	 */
	public int[] getSkills() {
		return skills;
	}

	/**
	 * returns the string representation of a Person.
	 * 
	 * @return the string representation of a Person
	 */
	public String toString() {
		return name;

	}
}
